using System.Collections.Generic;
using MathematicallySafe.HeadCounter.Data.Common;

namespace MathematicallySafe.HeadCounter.Services.Calculators
{
    public abstract class Processor<T>
    {
        public Processor() {}

        public void Execute(IEnumerable<T> collection)
        {
            Initialise();
            collection.ForEach(Process);
            PostProcess();
        }

        public void Execute(T target)
        {
            Initialise();
            Process(target);
            PostProcess();
        }

        protected virtual void Initialise() {}
        protected abstract void Process(T item);
        protected virtual void PostProcess() {}
    }
}